/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package grex.fitnessfunctions.Regression;

/**
 *
 * @author RIK
 */
/*
 * SimplificationFunction.java
 *
 * Created on den 22 april 2007, 22:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


import grex.GP;
import grex.Data.Prediction;
import grex.fitnessfunctions.FitnessFunction;
import grex.fitnessfunctions.IFitnessFunction;

import java.io.Serializable;

/**
 *
 * @author rik
 */
public class SimplificationFitness extends FitnessFunction implements IFitnessFunction, Serializable{
    
    /** Creates a new instance of SimplificationFunction */
    public SimplificationFitness() {
        super("Simplification");
    }
    
    @Override
    protected double calcPredictionError(Prediction prediction, double targetValue) {
       double UAPE = Math.abs((prediction.getPrediction()- targetValue)/((prediction.getPrediction()+ targetValue)/2));
       return UAPE < 0.01  ? 0 : UAPE;
    }
    
    @Override
    protected double calcParismonyPressure(GP gp){
        return gp.getNrOfNodes()*0.05;
    }

}

